//引入第三方express模块
const express=require("express");
//引入第三方路由器模块
const router=express.Router();
//引入连接池
const pool=require("../pool")

//创建路由，端口
router.get("/",(req,res)=>{
  var sql="select * from useraccount"
  pool.query(sql,[],(err,result)=>{
    if(err) console.log(err);
    res.send(result)
  })
})

router.post('/update',(req,res)=>{
  var result=req.body;
  var $uid=result.uid;
  var $updatedAccount=result.updatedAccount;
  console.log($uid);
  var sql="update useraccount set useraccount=? where uid=?"
  pool.query(sql,[$updatedAccount,$uid],(err,result)=>{
    //console.log("111")
    if(err) throw err;
    //console.log(result);
    if(result.affectedRows>0){
      res.send("200")
    }
  })
})
//公开模块
module.exports=router;


